<template>
    <header>
        <div class="l-content">
            <el-button plain icon="el-icon-menu" size="mini"></el-button>
            <h3 style="color:#fff">首页</h3>
        </div>
        <div class="r-content">
            <el-dropdown trigger="click" size="mini">
                <span>
                    <img class="user" :src="userImg" >
                </span>
                  <el-dropdown-menu slot="dropdown">
    <el-dropdown-item @click.native="personal">个人中心</el-dropdown-item>
    <el-dropdown-item @click.native="open">退出</el-dropdown-item>
  </el-dropdown-menu>
            </el-dropdown>
        </div>
    </header>
</template>

 <style lang="less" scoped>
header{
    display: flex;
    height:100%;
    justify-content: space-between;
    align-items: center;
}
.l-content{
    display: flex;
    align-items: center;
    .el-button{
        margin-right: 20px;
    }
}
.r-content{
    .user{
        width: 40px;
        height: 40px;
        border-radius: 50%;
    }
}
</style>
<script>

export default {
   name:'CommonHeader',
   data(){
       return {
            userImg:require('../assets/images/user.png')
       }
   },
    methods: {
      personal(){
        this.$router.push('/home');
      },
      open() {
        this.$confirm(' 确认退出登录?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$router.push('/');
          this.$message({
            type: 'success',
            message: '退出登录成功!'
           
          });
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消退出！'
          });          
        });
      }
    }
}
</script>
